package com.yundasys.lab02springbootstudy.boot;

import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
import org.springframework.core.env.PropertySource;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.ResourcePropertySource;

import java.io.IOException;

/**
 * @author jiangta
 * @version 1.0
 * @date 2022/4/1 2:48 下午
 */
public class Step3 {

    public static void main(String[] args) throws IOException {
        StandardEnvironment environment = new StandardEnvironment();
        environment.getPropertySources().addLast(
                new ResourcePropertySource("step4", new ClassPathResource("step4.properties"))
        );
        ConfigurationPropertySources.attach(environment);
        for (PropertySource ps :environment.getPropertySources()) {
            System.out.println(ps);
        }
        System.out.println(environment.getProperty("user.first-name"));
        System.out.println(environment.getProperty("user.middle-name"));
        System.out.println(environment.getProperty("user.last-name"));
    }
}
